package com.hotel_management_backstage.lin.controller;

import com.hotel_management_backstage.lin.entity.SysUser;

import com.hotel_management_backstage.lin.result.RespBean;
import com.hotel_management_backstage.lin.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.security.Principal;


@RestController
public class LoginController {
    @Autowired
    SysUserService sysUserService;

    @GetMapping("/admin/info")
    public SysUser getSysUserInfo(Principal principal){
        if(null==principal){
            return null;
        }
        String name = principal.getName();
        SysUser sysUser = sysUserService.selectByName(name);
        sysUser.setPassword(null);
        return sysUser;
    }


    @GetMapping("/api/logout")
    public RespBean logout(){
        return RespBean.success("注销成功！");
    }

}
